#include "study_widget.h"

study_widget::study_widget(QWidget *parent) : QWidget(parent)
{
    main_box = new QVBoxLayout;
    m_top_widget = new study_widget_top(this);
    m_middle_widget = new study_widget_middle(this);
    m_bottom_widget = new study_widget_bottom(this);
    pButtonScaleBig = new QPushButton(QString("放大"));
    pButtonScaleSmall = new QPushButton(QString("缩小"));
    pButtonReset = new QPushButton(QString("重置"));
    vButtonLayout = new QHBoxLayout;
    hBottomLayout = new QVBoxLayout;

    /* 2.连接信号槽 */
    pButtonScaleBig->setFixedSize(QSize(80, 30));
    pButtonScaleSmall->setFixedSize(QSize(80, 30));
    pButtonReset->setFixedSize(QSize(80, 30));
    connect(m_top_widget,SIGNAL(sigPenStudy(qint64)),m_bottom_widget,SLOT(onStyStatusChanged(qint64)));
    connect(pButtonScaleBig, SIGNAL(clicked(bool)), this, SLOT(pButtonScaleBigClicked()));
    connect(pButtonScaleSmall, SIGNAL(clicked(bool)), this, SLOT(pButtonScaleSmallClicked()));
    connect(pButtonReset, SIGNAL(clicked(bool)),this, SLOT(pButtonResetClicked()));


    /* 3.布局 */
    vButtonLayout->addStretch();
    vButtonLayout->addWidget(pButtonScaleBig);
    vButtonLayout->addWidget(pButtonScaleSmall);
    vButtonLayout->addWidget(pButtonReset);
    vButtonLayout->setSpacing(10);
    vButtonLayout->setMargin(0);

    hBottomLayout->addLayout(vButtonLayout);
    hBottomLayout->addWidget(m_bottom_widget);
    hBottomLayout->setSpacing(10);
    hBottomLayout->setMargin(0);

    main_box->addWidget(m_top_widget);
    main_box->addWidget(m_middle_widget);

    main_box->addStretch();
    main_box->addLayout(hBottomLayout);
    main_box->addStretch();

    main_box->setSpacing(0);
    main_box->setMargin(0);             //设置外边距

    this->setContentsMargins(0,0,0,0);
    this->setLayout(main_box);
    this->setStyleSheet("*{font-family:Microsoft Yahei;}\
                            QPushButton{font-family:Microsoft Yahei;color:white;background-color:rgb(14 , 150 , 254);border-radius:3px;}\
                            QPushButton:hover{background-color:rgb(44 , 137 , 255);}\
                            QPushButton:pressed{background-color:rgb(14 , 135 , 228);padding-left:2px;padding-top:2px;}\
                            QScrollBar:vertical{background: white;width:10px;margin: 10px 0px 10 0px;}\
                            QScrollBar::handle:vertical{border-radius:3px;background:lightgray;border-width:2 0 2 0;}\
                            QScrollBar:horizontal{background:white; height: 8px; }\
                            QScrollBar::handle:horizontal{border-radius:3px;background:gray;}");
}

void study_widget::paintEvent(QPaintEvent *event)
{
    QStyleOption opt;
    opt.init(this);
    QPainter p(this);
    style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
}

